package com.yun.algorithmproblem.leetcode;

import java.util.LinkedList;

public class Leetcode155 {
    static class MinStack {
        record Data(int val,int min){

        }
        LinkedList<Data> stack=new LinkedList<>();

        public MinStack() {
        }

        public void push(int val) {
            if(stack.isEmpty()){
                stack.push(new Data(val,val));
            }else {
                stack.push(new Data(val,Math.min(val,stack.peek().min)));
            }
        }

        public void pop() {
            stack.pop();
        }

        public int top() {
            return stack.peek().val;
        }

        public int getMin() {
            return stack.peek().min;
        }
    }
}
